/**
 * 
 */
package it.fuesi.expired.api.controllers;

import it.fuesi.expired.api.TagService;
import it.fuesi.expired.api.controllers.base.ACrudController;
import it.fuesi.expired.model.Tag;
import it.fuesi.expired.model.base.ErrorModel;
import it.fuesi.expired.model.base.ModelCollection;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author pascotto
 *
 */
@Controller
public class TagController extends ACrudController<Tag> implements TagService{

	
	@RequestMapping(method = RequestMethod.GET, value = BASE_URI)
	@ResponseBody()
	public ModelCollection<Tag> getAll() throws Exception{
		return super.getAll();
	}
	
	@RequestMapping(method = RequestMethod.GET, value = BASE_URI + "/{_id}")
	@ResponseBody
	public Tag getOne(@PathVariable String _id) throws Exception{
		return super.get(_id);
	}
	
	@RequestMapping(method=RequestMethod.POST, value=BASE_URI)
	@ResponseBody
	public Tag add(@RequestBody Tag tag) throws Exception{
		return super.add(tag);
	}
	
	@RequestMapping(method=RequestMethod.PUT, value=BASE_URI)
	@ResponseBody
	public Tag update(@RequestBody Tag tag) throws Exception{
		return super.update(tag);
	}
	
	@RequestMapping(method = RequestMethod.DELETE, value = BASE_URI + "/{_id}")
	@ResponseBody
	public ErrorModel deleteOne(@PathVariable String _id) throws Exception{
		return super.delete(_id);
	}
	
	@RequestMapping(method = RequestMethod.DELETE, value = BASE_URI)
	@ResponseBody
	public ErrorModel deleteAll() throws Exception{
		return super.deleteAll();
	}
	
}
